<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            box-sizing: border-box;
            width: 500px;
            height: 300px;
            margin: 0 auto;
            font-size: 30px;
            text-align: center;
            background-color: red;
            padding: 50px;
        }
    </style>
</head>

<body>
    <div>
        <p>随机英雄</p>
        <button>开始</button>
    </div>
    <script>
        // 4、随机点名.html
        var text = document.querySelector('p');
        var btn = document.querySelector('button');
        var boo = true;
        var getRandow = (min, max) => Math.floor(Math.random() * (max - min) + min);
        var arr = ['疾风剑豪', '熔岩巨兽', '元素女皇', '沙漠玫瑰', '深海泰坦', '无双剑姬', '暗夜猎手']
        btn.onclick = () => {
            btn.innerText = btn.innerText == '开始' ? '结束' : '开始'
            var timer = setInterval(() => {
                if (btn.innerText == '开始') clearInterval(timer)
                text.innerText = arr[getRandow(0, arr.length)]
            }, 100);
        }
    </script>
</body>

</html>